package com.zy.ivideo.service;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.zy.ivideo.entity.UserEntity;
import org.springframework.stereotype.Service;

@Service("TokenService")
public class TokenService {

    /**
     * 获取token
     * @param userInfo
     * @return
     */
    public String getUserToken(UserEntity userInfo) {
        String token = "";
        token = JWT.create().withAudience(userInfo.getUsername())
                .sign(Algorithm.HMAC256(userInfo.getUsername()));
        return token;
    }

}
